package oaSystem.web.security;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import oaSystem.web.security.exception.AuthorityException;

@ControllerAdvice(annotations=Controller.class)
public class AuthorityExceptionHandler {
	
	@ExceptionHandler(value=AuthorityException.class)
	public String handle(AuthorityException ex,Model model){
		System.out.println(ex.getMessage());
		String message = ex.getMessage();
		if(message!=null&&"login".equals(message)){
			return "redirect:/login";
		}
		return "redirect:/error";
	}
}
